import sys
import time

sys.path.append("../../")
import bmf


def test():
    input_video_path = "../../files/big_bunny_1min_30fps.mp4"
    output_path = "./output.mp4"

    graph = bmf.graph()
    video = graph.decode({
        "input_path": input_video_path,
        "video_params": {
            "hwaccel": "cuda",
            # "pix_fmt": "yuv420p",
        }
    })
    (video['video'].module('scale_gpu', {
        "size": '1920x1080',
        'algo': 'cubic'
    }).module('crop_gpu', {
        'x': 960,
        'y': 540,
        'width': 640,
        'height': 480
    }).module('flip_gpu', {
        'direction': 'h'
    }).module('rotate_gpu', {
        'angle': 'pi/8'
    }).module('blur_gpu', {
        'op': 'gblur',
        'sigma': [0.7, 0.7],
        'size': [5, 5]
    }).encode(
        None, {
            "output_path": output_path,
            "video_params": {
                "codec": "hevc_nvenc",
                "pix_fmt": "cuda",
            }
        }).run())


if __name__ == '__main__':
    test()
